compareFuncs
With this method, you can compare the execution time of several functions and get complete information from it
Params
function compareFuncs(runtimeCount = 5, ...inputFunctions);
- runtimeCount → The number of times you want input functions to be executed and its time taken
- inputFunctions → The functions we want to compare their execution time with each other and compare
Returns
{
firstRuntimes: {
fastest: [ [Function: inpFunc3], 0.00604 ],
slowest: [ [Function: inpFunc1], 0.07471 ],
rank: [ [Array], [Array], [Array] ]
},
multiRuntimes: {
fastestRun: [ [Function: inpFunc1], 0.00033 ],
slowestRun: [ [Function: inpFunc2], 0.00204 ],
fastestAverage: [ [Function: inpFunc3], 0.00036 ],
slowestAverage: [ [Function: inpFunc2], 0.00085 ],
result: [ [Array], [Array], [Array] ]
}
}
-
Object.firstRuntimes → Comparison of functions in the first run
-
Object.firstRuntimes.fastest → Fastest execution time among functions
-
Object.firstRuntimes.slowest → Slowest execution time among functions
-
Object.firstRuntimes.rank → Execution time of all functions in the order of fastest to slowest
-
Object.multiRuntimes → Comparison of functions in the next several times of execution (by the number of runtimeCount)
-
Object.multiRuntimes.fastestRun → Fastest execution time among functions
-
Object.multiRuntimes.slowestRun → Slowest execution time among functions
-
Object.multiRuntimes.fastestAverage → Fastest execution time among functions
-
Object.multiRuntimes.slowestAverage → Slowest execution time among functions
-
Object.multiRuntimes.result → Execution times of each function(like getMultiRuntime())
Usage
const inpFunc1 = ()=>{
let a = 324563;
let b = 232143214;
c = b - a;
c = c**2;
}
const inpFunc2 = () => {
let a = 324563;
let b = 232143214;
c = b - a;
c = c ** 3;
};
const inpFunc3 = () => {
let a = 324563;
let b = 232143214;
c = b - a;
c = c ** 4;
};
momentMachine.compareFuncs(5,inpFunc1,inpFunc2,inpFunc3);
/*
{
firstRuntimes: {
fastest: [ [Function: inpFunc3], 0.00604 ],
slowest: [ [Function: inpFunc1], 0.07471 ],
rank: [ [Array], [Array], [Array] ]
},
multiRuntimes: {
fastestRun: [ [Function: inpFunc1], 0.00033 ],
slowestRun: [ [Function: inpFunc2], 0.00204 ],
fastestAverage: [ [Function: inpFunc3], 0.00036 ],
slowestAverage: [ [Function: inpFunc2], 0.00085 ],
result: [ [Array], [Array], [Array] ]
}
}
*/